package com.adong.jpa.dao;

import com.adong.jpa.entities.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContext;
import javax.swing.text.html.parser.Entity;

/**
 * @author adong
 */
@Repository
public class PersonDao {

    //通过@PersistenceContext注解来标记成员变量,当前事务的关联的EntityManager对象
    @PersistenceContext
    private EntityManager entityManager;


    public void save(Person person) {
        entityManager.persist(person);
    }

}
